﻿/*!
* jQuery DivMenu plugin: 
* 
* version 0.1 2010-03-08
* Requires jQuery v1.3.2 or later
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
* Authors: Kim Seoung Min
*/
; (function($) {
    if (!$.KDBJQ) { $.KDBJQ = new Object();  };

    $.KDBJQ.DivMenu = function(el, liname, title) {
        // To avoid scope issues, use 'base' instead of 'this'
        // to reference this class from internal events and functions.
        var base = this;

        // Access to jQuery and DOM versions of element
        base.$el = $(el);
        base.el = el;

        // Add a reverse reference to the DOM object
        base.$el.data("KDBJQ.DivMenu", base);

        base.init = function() {
            base.liname = liname;
            // Put your initialization code here
        };

        // Sample Function, Uncomment to use
        base.show = function() {
            // Menu li :alert(base.liname);
            base.$menu = $("#" + base.liname);
            //alert(base.$menu.css);
            base.$body.append(base.$menu.html());

        };

        // Run initializer
        base.init();

        base.$el.append("<div class='DivSpanTop'></div>"); /// <reference path="../../image/ElementBlueArrowDown.gif" />

        base.$top = base.$el.find('> .DivSpanTop');
        base.$top.append("<a>" + title + "</a><img title='expend' alt='' class='DivSpanimg' src='/image/ElementBlueArrowDown.gif' />");
        base.$el.append("<div class='DivSpanBody'></div>")
        base.$body = base.$el.find('>.DivSpanBody');
//        base.$body = $('.DivSpanBody');
        base.show();

        base.$top.bind("click", function() {
            var color = base.$body.css("display");
            if (color == "none") {
                base.$body.css("display", "block")
                base.$top.find('> .DivSpanimg').attr({ src: "/image/ElementBlueArrowDown.gif" });
            }
            else {
                base.$body.css("display", "none")
                base.$top.find('> .DivSpanimg').attr({ src: "/image/ElementBlueArrowUp.gif" });
            }
        });
    };

    $.KDBJQ.DivMenuShow = function(el) {
    alert($(el).html());
    };

    $.KDBJQ.DivMenu.defaultOptions = {
};

$.fn.DivMenu = function(liname, title) {
    return this.each(function() {
        (new $.KDBJQ.DivMenu(this, liname, title));
    });
};

$.fn.DivMenuShow = function() {
    return this.each(function() {
        (new $.KDBJQ.DivMenuShow(this));
    });
};

})(jQuery);